// window.dash_clientside = Object.assign({}, window.dash_clientside, {
//     clientside: {
//         large_params_function:     function(){
//             console.log('#####',dash_clientside.callback_context);
//             const triggered_id = dash_clientside.callback_context.triggered_id;
//             return "triggered id: " + triggered_id
//         }
//     }
// });
// import * as echarts from 'echarts';


window.dash_clientside = Object.assign({}, window.dash_clientside, {
    clientside: {
        switch_chart:function(){
            
            var tt=dash_clientside.callback_context;
            // console.log('#####',chartType);
            console.log('#####',tt);
            // console.log('#####',tt["states"]["chart-type.value"]);
            // console.log('@@@@',dash_clientside.callback_context.states.chartType);
            const triggered_id = dash_clientside.callback_context.triggered_id;
            console.log('@@@@',triggered_id);
            chartType=tt["states"]["chart-type.value"];
            if (chartType == '柱状图'){
                var myChart = echarts.init(document.getElementById('main'));
                myChart.clear() ; 
                option = {
                    xAxis: {
                      type: 'category',
                      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                    },
                    yAxis: {
                      type: 'value'
                    },
                    series: [
                      {
                        data: [120, 200, 150, 80, 70, 110, 130],
                        type: 'bar'
                      }
                    ]
                  };         
                      
                return myChart.setOption(option); 
            };
            if (chartType == '折线图'){
                var myChart = echarts.init(document.getElementById('main'));
                myChart.clear() ;
                option = {
                    xAxis: {
                        type: 'category',
                        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [
                        {
                        data: [150, 230, 224, 218, 135, 147, 260],
                        type: 'line'
                        }
                    ]
                    };            
                      
                return myChart.setOption(option); 
            };

 
        }
    }
});